<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="renderer" content="webkit|ie-comp|ie-stand">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <title>开发日志</title>
  <script src="../../../static/kaige/js/szload.js"></script>
</head>

<body>
  <div class="kaige-body kaige-btn-radius">
    <table class="layui-table" id="pageTable" lay-filter="pageTable"></table>
  </div>

  <script>
    load_init_js([szoapcpath + '/static/lib/iceEditor/iceEditor.js'], function () {
      layui.config({
        base: szoapcpath + '/static/kaige/layuiextend/'
      }).use(['kaige'], function () {
        var element = layui.element,
          layer = layui.layer,
          table = layui.table,
          form = layui.form,
          kaige = layui.kaige,
          laydate = layui.laydate,
          $ = layui.$;
        var loadnum = 0;

        kaige.table({
          elem: '#pageTable',
          url: "/sys.dev_log/index",
          id: 'pageTable',
          toolbar: '#dtoolbar',
          defaultToolbar: ['filter'],
          height: 'full-35',
          cols: [[
            { field: 'id', title: 'ID', align: 'center', width: 90 },
            { field: 'title', title: '标题', align: 'center', width: 300 },
            { field: 'user_id_name', title: '开发人员', align: 'center', width: 130 },
            { field: 'start', title: '开始时间', align: 'center', width: 180 },
            { field: 'end', title: '结束时间', align: 'center', width: 180 },
            { field: 'create_time', title: '创建时间', align: 'center', width: 180 },
            { title: '操作', toolbar: '#dtrbar', align: 'center', width: 150, fixed: 'right' }
          ]]
        });


        //列表-监听表头工具栏事件dtoolbar
        table.on('toolbar(pageTable)', function (obj) {
          switch (obj.event) {
            case 'btn-add':
              btnadd();
              break;
          }
        });

        //列表-监听单元格行工具事件dtrbar
        table.on('tool(pageTable)', function (obj) {
          var that = this;
          var data = obj.data;
          switch (obj.event) {
            case 'edit':
              baredit(data);
              break;
            case 'del':
              bardel(data);
              break;
          }
        });

        //添加
        function btnadd() {
          kaige.form({
            url: "/sys.dev_log/add",
            data: {},
            id: 'kaige',
            area: ['93%', '80%'],
            title: '<i class="layui-icon layui-icon-add-circle"></i> 添加 - 开发日志',
            tablelayid: 'pageTable',
            overflow: false,
            encode: 1,
            callbefore: function (layero, index, res) {
              addeditform(res);
            }
          });
        }

        //编辑
        function baredit(d) {
          kaige.form({
            url: "/sys.dev_log/edit",
            data: { id: d.id },
            id: 'kaige',
            area: ['93%', '80%'],
            title: '<i class="layui-icon layui-icon-edit"></i> 编辑 - 开发日志',
            tablelayid: 'pageTable',
            overflow: false,
            encode: 1,
            callbefore: function (layero, index, res) {
              addeditform(res);
            },
          });
        }

        function addeditform(d) {
          //备注
          var gwe = new ice.editor('content');
          gwe.height = '400px';  //高度
          gwe.create();
          if (d && d.content) {
            gwe.setValue(d.content);
          }

          laydate.render({
            elem: '.formtimed'
            , type: 'date'
          });

        }

        //删除
        function bardel(d) {
          layer.confirm('您确定删除吗？', {
            title: '<i class="layui-icon layui-icon-delete"></i> 删除确认',
            btn: ['确认', '取消']
          }, function () {
            $.post("/sys.dev_log/del", { id: d.id }, function (res) {
              res.status && table.reload('pageTable');
              layer.msg(res.msg);
            });
          });
        };

      });
    });
  </script>
  <script type="text/html" id="dtrbar">
    <div class="layui-btn-group">
      <button type="button" class="layui-btn layui-btn-sm layui-bg-blue" lay-event="edit" title="编辑"><i class="layui-icon layui-icon-edit"></i></button>
      <button type="button" class="layui-btn layui-btn-sm layui-bg-red" lay-event="del" title="删除"><i class="layui-icon layui-icon-delete"></i></button>
    </div>
  </script>
  <script type="text/html" id="dtoolbar">
    <div class="layui-form" lay-filter="page_search_box">
      <div class="layui-btn-group">
        <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-add"><i class="layui-icon layui-icon-add-circle"></i> 添加</button>
      </div>
    </div>
  </script>
  <script type="text/html" id="kaige_form_html">
    <form class="layui-form layui-form-pane kaige-body-form" lay-filter="kaige_form_lay_filter">
      {{# if(d.id){ }}
      <input type="hidden" name="id" value="{{ d.id }}" />
      {{# } }}
      <div class="layui-form-item">
        <label class="layui-form-label">开发人员</label>
        <div class="layui-input-inline">
          <input name="user_id" value="{{ d.einfo.real_name || '' }}" class="layui-input layui-disabled" disabled type="text">
          <input name="user_id" value="{{ d.user_id ? d.user_id : d.einfo.id }}" type="hidden">
        </div>
      </div>
      <div class="layui-form-item">
        <div class="layui-form-item">
          <label class="layui-form-label">标题</label>
          <div class="layui-input-block">
            <input name="title" value="{{ d.title || '' }}" class="layui-input" type="text" >
          </div>
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">内容</label>
        <div class="layui-input-block">
          <textarea name="content"  id="content" class="layui-textarea" >{{- d.content || '' }}</textarea>
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">开始时间</label>
        <div class="layui-input-inline">
          <input name="start" value="{{ d.start || '' }}" class="layui-input formtimed" type="text">
        </div>
        <label class="layui-form-label">结束时间</label>
        <div class="layui-input-inline">
          <input name="end" value="{{ d.end || '' }}" class="layui-input formtimed" type="text">
        </div>
      </div>    
      <div class="layui-form-item layui-hide">
        <button class="layui-hide" lay-submit="" id="kaige_form_btn_save" lay-filter="kaige_form_btn_save">保存数据</button>
      </div>
    </form>
  </script>
</body>

</html>